<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no">

    <link href="//cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
    <script src="//cdn.bootcss.com/jquery/2.1.4/jquery.min.js"></script>
    <script src="//cdn.bootcss.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>

    <link href="/stylesheets/style.css" rel="stylesheet">
    <script src="/javascripts/lib/jquery.cookie.min.js"></script>
    <script src="/javascripts/common.js"></script>
    <title>合作方登录</title>
</head>
<body>
<div class="background">
    <img src="/images/background.png" height="100%" width="100%"/>
</div>
<div>
    <div class="login-label">&nbsp;&nbsp;&nbsp;&nbsp;登&nbsp;录</div>

    <form class="form-horizontal col-xs-9 col-xs-offset-1 col-sm-9 col-sm-offset-1">
        <div class="form-group margin-top">
            <label class="col-xs-3 col-sm-3 control-label">账号</label>

            <div class="col-sm-9 col-xs-9">
                <input type="text" class="form-control" id="account" placeholder="请输入账号"/>
            </div>
        </div>
        <div class="form-group margin-top">
            <label class="col-sm-3 col-xs-3 control-label">密码</label>

            <div class="col-sm-9 col-xs-9">
                <input type="password" class="form-control" id="password" placeholder="请输入密码"/>
            </div>
        </div>

        <div class="form-group margin-top">
            <div class="col-sm-offset-2 col-sm-10 col-xs-offset-2 col-xs-10 margin-top-20">
                <button type="button" id="login" class="btn btn-xs btn-warning col-xs-10
                    col-sm-10 col-xs-offset-1 col-sm-offset-1">&nbsp;&nbsp;登录&nbsp;&nbsp;</button>
            </div>
        </div>
    </form>
</div>

<script>
    $("#login").click(function () {
        if (!!$("#account").val() && !!$("#password").val()) {
            $.post("/driver/login", {username: $("#account").val(), password: $("#password").val()} ,function(data){
                if(data === 'success') {
                    window.location.href = '/driver/index';
                } else {
                    window.utils.toast('error','用户名或密码错误');
                }
            });
        } else {
            window.utils.toast('error','输入有误');
        }
    });
</script>
</body>
</html>